/**
 * 格式化日期
 */
export function formateDate(time: string | number | Date) {
  if (!time) return '';
  const date = new Date(time);

  // let week;
  // if (date.getDay() === 0) { week = "天" };
  // if (date.getDay() === 1) { week = "一" };
  // if (date.getDay() === 2) { week = "二" };
  // if (date.getDay() === 3) { week = "三" };
  // if (date.getDay() === 4) { week = "四" };
  // if (date.getDay() === 5) { week = "五" };
  // if (date.getDay() === 6) { week = "六" };

  // return date.getFullYear() + '-' + getDouble((date.getMonth() + 1)) + '-' + date.getDate() + ' 星期' + week + ' ' + getDouble(date.getHours()) + ':' + getDouble(date.getMinutes())
  return (
    '当前时间：' +
    date.getFullYear() +
    '-' +
    getDouble(date.getMonth() + 1) +
    '-' +
    date.getDate() +
    '  ' +
    getDouble(date.getHours()) +
    ':' +
    getDouble(date.getMinutes()) +
    ':' +
    getDouble(date.getSeconds())
  );
}

/**
 * 优化时间
 * */
function getDouble(num: string | number) {
  return num < 10 ? '0' + num : num;
}
